﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Configuration;

namespace CrawlServiceCore.Configuration
{
    public class CrawlListElement:ConfigurationElement
    {

        #region Properties
        [ConfigurationProperty("listname", IsRequired=true, IsKey=true)]
        [SettingsDescription("The display name / title of the list to be crawled for details.")]
        public string ListName
        {
            get { return (string)this["listname"]; }
            set { this["listname"] = value; }
        }

        [ConfigurationProperty("query", IsRequired = true)]
        [SettingsDescription("The CAML query to be used to retrieve the items from the given list.")]
        public string Query
        {
            get { return XmlConvert.DecodeName((string)this["query"]); }
            set { this["query"] = XmlConvert.EncodeName(value); }
        }

        [ConfigurationProperty("usernamefield", IsRequired = true)]
        [SettingsDescription("SharePoint Internal Field name which the user name will be pulled from.")]
        public string UsernameField
        {
            get { return (string)this["usernamefield"]; }
            set { this["usernamefield"] = value; }
        }
       
        [ConfigurationProperty("descriptionfield", IsRequired = true)]
        [SettingsDescription("SharePoint Internal Field name which a description/details will be pulled from.")]
        public string DescriptionField
        {
            get { return (string)this["descriptionfield"]; }
            set { this["descriptionfield"] = value; }
        }
        #endregion

        public CrawlListElement()
        { }

        public CrawlListElement(string listName)
        {
            this.ListName = listName;
        }
    }
}
